import * as vscode from 'vscode';
import { ProxyService } from "../../../src/services/proxyService";

export class DocLinterWebviewRequestHandler {
    private proxyService: ProxyService;

    constructor(private context: vscode.ExtensionContext, private webview: vscode.Webview) {
        this.context = context;
        this.webview = webview;
        this.proxyService = ProxyService.getInstance(this.context);
    }


    /**
     * 处理获取记录
     */
    public async handleFetchRecord(data: any): Promise<void> {
        const { page, pageSize } = data;
        const url = `/api/aiService/report/getAll?pageNum=${page}&pageSize=${pageSize}`;
        const res = await this.proxyService.get(url);
        if (res.success) {
            this.webview.postMessage({
                messageType: "fetchRecordCallback",
                data: res.data,
            });
        }
    } 
}   